#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 510 + 10;
const int S = 1 << 12;
const int mod = 998244353;

int f[N][S];
int a[N], usd[N], n, D, ans;

int isset(int i, int s, int g) { return i + g > n || i + g <= 0 ? 1 : a[i + g] != -1 || (s >> g + D & 1); }

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in; D = in; rep(i, 1, n) a[i] = in, (a[i] != -1) && (usd[a[i]] = true);
	f[1][0] = 1; int U = 1 << D + D + 1; U--;
	rep(i, 1, n + 1)
		rep(s, 0, U)
		if(f[i][s]) {
			//	cerr << i << " " << s << endl;
			if(i == n + 1) { (ans += f[i][s]) %= mod; continue; }
			if(!usd[i]) {
				rep(j, -D, D)
					if(!isset(i, s, j)) {
						if(j == -D) {
							(f[i + 1][s >> 1] += f[i][s]) %= mod;
							break;
						} else {
							(f[i + 1][s >> 1 | (1 << (j + D - 1))] += f[i][s]) %= mod;
						}
					}
			} else {
				if(!isset(i, s, -D)) continue;
				(f[i + 1][s >> 1] += f[i][s]) %= mod;
			}
		}
	cout << ans << endl;
	return 0;
}
